home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
satellit
/
pgdir
/
pgdir.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-02-21
|
2KB
|
79 lines
/**************************************************************************/
/* pgdir.c Simple Display Utility for the Directory Files */
/* PG.DIR and PGARCH.DIR of an Microsat. */
/* 21Feb91 by Peter Gülzow DB2OS */
/**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "pgdir.h"
/* Globals */
char time_stamp[12];
/* Functions */
char *ptime(time_t);
/**************************************************************************/
/** main ****************************************************************/
/**************************************************************************/
main(int argc, char * argv[])
{
struct SHORT_DIR dir;
FILE *fp;
int i;
if (argc < 2)
{
printf("usage: pgdir <filename.dir>\n");
exit(-1);
}
if ( (fp=fopen(argv[1], "rb")) == NULL)
{
printf("File <%s> does not exist.\n",argv[1]);
exit(-2);
}
printf("\n** Directory of '%s' **\n\n",argv[1]);
puts(" File From To Date Time Size Title");
puts("-------------------------------------------------------------------------------");
i=0;
while (!feof(fp))
{
if (fread(&dir, sizeof(struct SHORT_DIR), 1, fp))
{
printf("%8lx %-8.8s %-8.8s %-11.11s %6ld %-.33s\n",
dir.fnumber,
dir.source,
dir.dest,
ptime(dir.ultime),
dir.fsize,
dir.title
);
i++;
}
}
printf("\n %d entries listed.\n",i);
fclose(fp);
return;
}
/*------------------------------------------------------------------------*/
/* ptime() Print Time gives a short timestamp dd/mm hh:mm */
/*------------------------------------------------------------------------*/
char *ptime(time_t utc)
{
struct tm *pt;
pt = gmtime(&utc);
sprintf(time_stamp, "%02d/%02d %02d:%02d",
pt->tm_mday, pt->tm_mon+1,
pt->tm_hour, pt->tm_min
);
return time_stamp;
}